xen/nested_p2m: Don't walk EPT tables with a regular PT walker
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 12 Apr 2016 18:57:35 +0000 (19:57 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 May 2016 17:22:06 +0000 (18:22 +0100)
commitbab2bd8e222de9e596699ac080ea985af828c4c4
tree6b495c8ef38eda16f776a6a32e475235499f16d9
parent8b1834afdde1c0e19d92bd040ed08d3943e5f2eb
xen/nested_p2m: Don't walk EPT tables with a regular PT walker

hostmode->p2m_ga_to_gfn() is a plain PT walker, and is not appropriate for a
general L1 p2m walk.  It is fine for AMD as NPT share the same format as
normal pagetables.  For Intel EPT however, it is wrong.

The translation ends up correct (as the formats are sufficiently similar), but
the control bits in lower 12 bits differ in meaning.  A plain PT walker sets
A/D bits (bits 5 and 6) as it walks, but in EPT tables, these are the IPAT and
top bit of EMT (caching type).  This in turn causes problem when the EPT
tables are subsequently used.

Replace hostmode->p2m_ga_to_gfn() with nestedhap_walk_L1_p2m() in
paging_gva_to_gfn(), which is the correct function for the task.  This
involves making nestedhap_walk_L1_p2m() non-static, and adding
vmx_vmcs_enter/exit() pairs to nvmx_hap_walk_L1_p2m() as it is now reachable
from contexts other than v == current.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/vmx/vvmx.c
xen/arch/x86/mm/hap/nested_hap.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/hvm/nestedhvm.h